import Vue from 'vue'
import Router from 'vue-router'

import Layout from '@/views/layout/layout'

Vue.use(Router)

export const constantRouterMap = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'home',
    children: [
      {
        path: 'home',
        component: () => import('@/views/home/index'),
        name: 'home',
        meta: {title: '首页', icon:'dashboard', noCache: true}
      }
    ]
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
]

export default new Router({
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/pdf',
    component: Layout,
    alwaysShow: true,
    meta: {
      title: 'PDF操作',
      icon: 'pdf',
      roles: ['admin', 'common']
    },
    children: [
      {
        path: 'pdf',
        component: () => import('@/views/pdf/pdf'),
        name: 'pdf',
        meta: { title: 'PDF操作' }
      }
    ]
  },
  {
    path: '/pic',
    component: Layout,
    alwaysShow: true, //控制后面的折叠按钮，有子菜单就要设为true
    meta: {
      title: '图像操作',
      icon: 'pic',
      roles: ['admin', 'common']
    },
    children: [
      {
        path: 'pic',
        component: () => import('@/views/pic/pic'),
        name: 'pic',
        meta: { title: '图像操作' }
      }
    ]
  },
  {
    path: '/qr',
    component: Layout,
    alwaysShow: true, //控制后面的折叠按钮，有子菜单就要设为true
    meta: {
      title: '二维码',
      icon: 'QR_code',
      roles: ['admin', 'common']
    },
    children: [
      {
        path: 'qr',
        component: () => import('@/views/qr/qr'),
        name: 'qr',
        meta: { title: '二维码' }
      }
    ]
  },
  {
    path: '/text',
    component: Layout,
    alwaysShow: true, //控制后面的折叠按钮，有子菜单就要设为true
    meta: {
      title: '文本工具',
      icon: 'text',
      roles: ['admin', 'common']
    },
    children: [
      {
        path: 'text',
        component: () => import('@/views/text/text'),
        name: 'text',
        meta: { title: '文本工具' }
      }
    ]
  },
  {
    path: '/number',
    component: Layout,
    alwaysShow: true, //控制后面的折叠按钮，有子菜单就要设为true
    meta: {
      title: '数字工具',
      icon: 'number',
      roles: ['admin', 'common']
    },
    children: [
      {
        path: 'number',
        component: () => import('@/views/number/number'),
        name: 'number',
        meta: { title: '数字工具' }
      }
    ]
  },
  {
    path: '/chart',
    component: Layout,
    alwaysShow: true, //控制后面的折叠按钮，有子菜单就要设为true
    meta: {
      title: '图表操作',
      icon: 'chart',
      roles: ['admin', 'common']
    },
    children: [
      {
        path: 'zhuzhuangtu',
        component: () => import('@/views/chart/zhuzhuangtu'),
        name: 'zhuzhuangtu',
        meta: { title: '图表操作' }
      }
    ]
  },
  {
    path: '/feedback',
    component: Layout,
    alwaysShow: true, //控制后面的折叠按钮，有子菜单就要设为true
    meta: {
      title: '意见反馈',
      icon: 'form',
      roles: ['admin', 'common']
    },
    children: [
      {
        path: 'feedback',
        component: () => import('@/views/feedback/feedback'),
        name: 'feedback',
        meta: { title: '反馈信息' }
      }
    ]
  }
]
